import java.util.ArrayList;
import java.util.List;


public class P19 {
	public static void main(String[] args) {
		
		int year = 1900;
		int month = 1;
		int day = 1;
		int week = 1; //mon ..
		int count = 0;
		
		while (true) {
			System.out.println(year + " " + month + " " + day + " " + week);
			
			if (year == 2001) {
				break;
			}
			
			if (year >= 1901 && day == 1 && week == 0) {
				count++;
			}
			
			day++;
			week++;
			
			week = week%7;
			
			if (month == 4 || month == 6 || month == 9 || month == 11) {
				if (day > 30) {
					day = 1;
					month++;
				}
			} else if (month == 2) {
				if (year%4 == 0 && year%100 != 0 && year%400 == 0) {
					if (day > 29) {
						day = 1;
						month++;
					}
				} else {
					if (day > 28) {
						day = 1;
						month++;
					}
				}
			} else {
				if (day > 31) {
					day = 1;
					month++;
				}
			}
			
			if (month > 12) {
				month = 1;				
				year++;
			}
			
		}
		System.out.println(count);
	}
}